package com.alan.designMode.builder;

import java.util.ArrayList;

/**
 * Created by Alan on 17-8-28
 */
public abstract class CarModel {

    //顺序
    private ArrayList<String> sequence = new ArrayList<>();

    //启动
    protected abstract void start();

    //停止
    protected abstract void stop();

    //喇叭
    protected abstract void alarm();

    //引擎声
    protected abstract void engineBoom();

    public void run(){
      for (int i = 0; i < this.sequence.size(); i++){
          String actionName = this.sequence.get(i);
          if(actionName.equalsIgnoreCase("start")){
              this.start();
          }else if(actionName.equalsIgnoreCase("stop")){
              this.stop();
          }else if(actionName.equalsIgnoreCase("alarm")){
              this.alarm();
          }else if(actionName.equalsIgnoreCase("engineBoom")){
              this.engineBoom();
          }
      }
    }

    public void setSequence(ArrayList<String> sequence) {
        this.sequence = sequence;
    }
}
